#pragma once

#ifndef TOUCHSCREEN_H
#define TOUCHSCREEN_H

#include "cvhead.h"
#include "Filter.h"
#include "FilterFactory.h"
#include "BlobTracker.h"
#include "EventListener.h"
#include "Calibration.h"
#include "TouchData.h"
#include <string>
#include <vector>

#define THREAD_HANDLE HANDLE
#define THREAD_MUTEX_HANDLE HANDLE
#define THREAD_RETURN_TYPE void


using namespace std;

class TouchScreen
{
private:

	string default_config_file;
	vector<EventListener*> listeners;
	BlobTracker tracker;
	FilterFactory filterFac;
	Calibration calib;

	THREAD_HANDLE hThread;	//UI thread
	THREAD_MUTEX_HANDLE eventListMutex;

	void init_filter_factory ();
	void cam_to_world(TouchData &data);
	void fire_event(const vector<TouchData> &touch_data);


public:

	TouchScreen(void);
	~TouchScreen(void);

	static THREAD_RETURN_TYPE _processEntryPoint(void*);

	void init_calibration (const char* filename);
	void process(void);
	void start_process(void);

	void add_listener(EventListener* e) { listeners.push_back(e);	}

};

#endif